<template>
	<view class="agreement">
		<rich-text :nodes="data.content"></rich-text>
	</view>
</template>

<script>
	import {
		get
	} from '../../static/utils/request'
	import {
		Agreement
	} from '../../static/utils/service'
	export default {
		data() {
			return {
				data: {}
			}
		},
		onLoad(e) {
			this.setTitle(e)
			this.getData(e)
		},
		methods: {
			setTitle(e) {
				let title = ''
				switch (e.type) {
					case 'service':
						title = '服务协议'
						break
					case 'privacy':
						title = '隐私条款'
						break
				}
				uni.setNavigationBarTitle({
					title
				})
			},
			async getData(e) {
				const res = await get(Agreement.policy, {
					type: e.type
				}, '加载中')
				this.data = res.data
			}
		}
	}
</script>

<style>

</style>